﻿using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Workflow2211A.Application.DTO;
using Workflow2211A.Application.Services;
using Microsoft.AspNetCore.Authorization;
using Workflow2211A.Application.DTO.Outputs.Workflow;
using Workflow2211A.Application.DTO.Inputs.Workflow;

namespace Workflow2211A.API.Controllers
{
    /// <summary>
    /// 用户服务
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
   // [Authorize]//授权过滤器
    public class UserController : ControllerBase
    {
        /// <summary>
        /// 用户服务
        /// </summary>
        private readonly IUserService _userService;
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="userService">用户服务</param>
        public UserController(IUserService userService)
        {
            _userService = userService;
        }

        /// <summary>
        /// 用户登录
        /// </summary>
        /// <param name="input">输入参数</param>
        /// <returns>返回用户信息</returns>
        [HttpPost]
        [AllowAnonymous]//允许匿名访问（可以不登录就能访问）
        public APIResult<UserOutput> Login(UserLoginInput input)
        {
            return _userService.Login(input);
        }
        /// <summary>
        /// 获取用户信息
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public List<UserOutput> GetUser()
        {
            return _userService.GetUser();
        }
    }
}
